import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Ap0stoL2
 * Date: 2023-07-25
 * Time: 21:39
 */
//测试volatile
public class Ddemo13 {
    private volatile static int OK=0;

    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            while(OK==0){
                ;
            }
            System.out.println("t1 执行完毕. ");

        });

        Thread t2 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            System.out.println("输入非0 t1结束, 输入0t1 循环: ");

            OK=scanner.nextInt();

        });

        t1.start();
        t2.start();
    }

}
